package com.roadjava.mockito;

import com.roadjava.mockito.service.UserService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.Spy;
import org.mockito.junit.jupiter.MockitoExtension;

/**
 * @author Administrator
 * @date 2024/12/22 0:19
 */
public class InitMockOrSpyMethod2 {
    private UserService mockUserService;
    private UserService spyUserService;

    @BeforeEach
    public void init(){
        mockUserService = Mockito.mock(UserService.class);
        spyUserService = Mockito.spy(UserService.class);
    }

    @Test
    public void test1(){
        // true
        System.out.println(Mockito.mockingDetails(mockUserService).isMock());
        // false
        System.out.println(Mockito.mockingDetails(mockUserService).isSpy());
        // true
        System.out.println(Mockito.mockingDetails(spyUserService).isMock());
        // true：spy对象是另一种不同类型的 mock对象
        System.out.println(Mockito.mockingDetails(spyUserService).isSpy());
    }
}
